package docoffice.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import docoffice.doss.Patient;

public class AccountLock extends JPanel {
	
	private JLabel title, blank, username, blank2;
	
	private JTextField userField;
	
	private JButton search;
	
	public AccountLock() {
		title = new JLabel("Lock/Unlock Account");
		blank = new JLabel();
		blank2 = new JLabel();
		username = new JLabel("Enter username");
		userField = new JTextField(10);
		userField.addActionListener(new FieldListener());
		
		search = new JButton("Search");
		search.addActionListener(new SearchListener());
		
		setLayout(new GridLayout(3, 2, 15, 10));
		add(title);
		add(blank);
		add(username);
		add(userField);
		add(blank2);
		add(search);
		
		setPreferredSize(new Dimension(400, 125));
		setBackground(Color.WHITE);
	}
	
	private class FieldListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			String userInput = userField.getText();
		}
	}
	
	private class SearchListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			String userInput = userField.getText();
			Patient p = new Patient(userInput);
			p.lookupPatient(userInput);
			removeAll();
			revalidate();
			repaint();
			add(new AccountLock2(userInput));
		}
	}

}
